
OBJ = $(patsubst %.c,%.o,$(shell ls -1 $(PWD)/*.c ))

DEP = .depend
DD = $(patsubst $(PWD)/%.o,$(PWD)/.depend/%.d,$(OBJ))

files = $(OBJ)
D_FILE =  $(patsubst $(PWD)/%,$(PWD)/$(DEP)/%, $*).d  
cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<

DBSYS:$(DEP) $(OBJ)  header.h 
	@echo " LD     $(PWD)/$@" 
	@gcc -o $@ $(OBJ)


$(DEP):
	mkdir -p $(DEP)


%.o  :%.c   header.h
	@gcc -c $<
	@echo " CC    $<"
	@gcc -M $< >  $(patsubst $(PWD)/%,$(PWD)/$(DEP)/%, $*).d  
	@echo  " DEP    $(D_FILE) "


-include $(DD)



clean:
	@rm -rf $(OBJ)	
	@echo " CLEAN   $(PWD)/*.o "
	@rm -rf $(DEP)
	@echo " CLEAN   $(PWD)/$(DEP)*.d "
	@rm -rf DBSYS
	@echo " CLEAN   $(PWD)/DBSYS "

